package cate.game.play.skill.passive.god;

import cate.common.table.d.GD;
import cate.common.table.d.GDAttr;
import cate.common.table.d.GDSkill;
import cate.game.attr.FightAttr;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 使用治疗或增益类技能可为生命百分比最低目标额外治疗0.12*（1.1*自身pk减伤+0.25*自身伤害减免）*目标已损失生命值的血量，冷却1回合
 */
public class 愈之转化PH extends PassiveHandler {

	private double 系数;

	private double pk减伤系数;

	private double 伤害减免系数;

	//系数=1200&pk减伤系数=11000&伤害减免系数=2500
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		系数 = args.getWDouble("系数", 0d);
		pk减伤系数 = args.getWDouble("减伤系数", 0d);
		伤害减免系数 = args.getWDouble("加伤系数", 0d);
	}

	private int lastRound;

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (lastRound >= action.getRound().index) {
			return;
		}
		if (!action.getSkill().cfg.isSupportSkill()) {
			return;
		}
		Fighter target = TargetSelector.findOne(skill.owner, action.getTeamVs(), new TargetFilterParam().smallAttrSet(GDAttr.HP_CUR).scopeSet(GDSkill.Scope.WE));
		if (target == null) {
			return;
		}
		lastRound = action.getRound().index;
		FightAttr total = skill.owner.attr.total();
		double value = 系数 * (pk减伤系数 * total.pvpDown() + 伤害减免系数 * total.hurtIgn()) / GD.W_10000_0 * target.attr.total().hpLoss();
		target.attr.passiveHeal(action, skill.owner, value);
	}
}
